#ifndef ANALIZER_H
#define ANALIZER_H

#include <pthread.h>
#include <stdint.h>
#include <string>
#include <vector>

#include "dispatcher.h"
#include "PacketBuffer.h"
#include "Rules.h"

class Session;
class PacketBuffer;

class Analizer {
	PacketBuffer *_buf;
	pthread_t _thread;
	bool _stopping;
	bool _running;
	size_t _ipSize;
	size_t _tcpSize;
	int _num;
	const char *_host;
	unsigned short _port;

	int run();
	static void *threadWrapper(void *object);

	const std::vector< std::pair<std::string, RootRule *> > *_anomalies;

public:
	Analizer(const char *host, unsigned short port, int id, size_t ipSize, size_t tcpSize,
			const std::vector< std::pair<std::string, RootRule *> > &anomalies);
	~Analizer();

	void start();
	void stop();
	int wait();

	void push(Session *ses, const uint8_t *data, size_t length, size_t tcpOffset, bool closing);
};

#endif
